<div class="head_course" style="background-color:#A5C4E3">กระดานข่าว</div>
<%= link_to image_tag('/images/post-button.gif', :border => 0, :title => 'ตั้งคำถาม', :align => 'absmiddle'), {:action => 'new_topic', :id => @forum} %>
<div class="nav" style="margin:20px;">
<%= link_to 'Forum', {:action => 'forum_list'} %> -> <%= @forum.forum_name %>
</div>
<%= will_paginate @topics, :previous_label=>'หน้าก่อน', :next_label => "หน้าถัดไป" %>
<table align="center" class="discussion" style='width:100%;'>
  <tr>
    <th colspan="2">Topic</th><th>ตอบ</th><th>ผู้ตั้ง</th><th>อ่าน</th><th>ตอบล่าสุดเมื่อ</th>
  </tr>
  <% @topics.each do |topic| %>
    <tr>
      <td></td>
      <td><%= link_to topic.topic_name, {:action => 'view_topic', :id => topic}  %></td>
      <td align="center"><%= Answer.find(:all, :conditions => {:topic_id => topic.id, :status_flag => 'Y'}).length %></td>
      <td align="center"><%= topic.create_by || "anonymous" %></td>
      <td align="center"><%= topic.read_count %></td>
      <td align="center"><%= begin Answer.find(:first, :conditions => {:topic_id => topic.id, :status_flag => 'Y'}, :order => 'create_on desc').create_on.strftime("%d/%m/%Y %I:%M%p") rescue "" end %></td>
    </tr>
  <% end %>
</table>
<%= will_paginate @topics, :previous_label=>'หน้าก่อน', :next_label => "หน้าถัดไป" %>
